package com.gin.kotlin.no_gay_alliance.model

import android.os.Parcelable
import com.gin.nga.response.mission.MissionInfo
import kotlinx.parcelize.Parcelize
import java.time.ZonedDateTime

/**
 * 任务信息
 * @property id ID
 * @property name 名称
 * @property info 简易信息
 * @property detail 详细信息
 * @property status 状态信息
 * @property startTime 任务有效期(起)
 * @property endTime 任务有效期(止)
 * @property count 连续完成次数
 * @property total 总计完成次数
 * @property completedTime 完成时间
 * @property lastCountTime 上次计数时间
 * @property thisCountTime 本次计数的开始时间
 * @constructor
 */
@Parcelize
data class MissionInfoModel(
    val id: Int? = null,
    val name: String? = null,
    val info: String? = null,
    val detail: String? = null,
    val status: String? = null,
    val startTime: ZonedDateTime? = null,
    val endTime: ZonedDateTime? = null,
    val count: Int? = null,
    val total: Int? = null,
    val completedTime: ZonedDateTime? = null,
    val lastCountTime: ZonedDateTime? = null,
    val thisCountTime: ZonedDateTime? = null,
) : Parcelable {

    constructor(missionInfo: MissionInfo) : this(
        id = missionInfo.id,
        name = missionInfo.name,
        info = missionInfo.info,
        detail = missionInfo.detail,
        status = missionInfo.status,
        startTime = missionInfo.missionDetail?.startTime,
        endTime = missionInfo.missionDetail?.endTime,
        count = missionInfo.missionStatus?.count,
        total = missionInfo.missionStatus?.total,
        completedTime = missionInfo.missionStatus?.completedTime?.takeIf { it.toEpochSecond() != 0L },
        lastCountTime = missionInfo.missionStatus?.lastCountTime?.takeIf { it.toEpochSecond() != 0L },
        thisCountTime = missionInfo.missionStatus?.thisCountTime?.takeIf { it.toEpochSecond() != 0L },
        )

}
